package com.tools;

import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Paint;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JLabel;

public class BICButtonDegrade extends JButton {

	private static final long serialVersionUID = -4550766181748315549L;

	private Color couleurFond;
	private final Color couleurSurbrillance = new Color(255, 255, 255);
	private final Color couleurNormale = new Color(191, 36, 94);
	private final Color couleurBas = new Color(88, 89, 91);

	public BICButtonDegrade(String texte) {
		couleurFond = couleurNormale;
		JLabel lTexte = new JLabel(texte);
		lTexte.setForeground(Color.WHITE);
		lTexte.setFont(new Font("Calibri", Font.BOLD, 13));
		setLayout(new BorderLayout());
		add(lTexte, BorderLayout.CENTER);
		addMouseListener(new MouseListener() {
			public void mouseExited(MouseEvent e) {
				couleurFond = couleurNormale;
				repaint();
			}

			public void mouseEntered(MouseEvent e) {
				couleurFond = couleurSurbrillance;
				repaint();
			}

			public void mouseReleased(MouseEvent e) {
			}

			public void mousePressed(MouseEvent e) {
			}

			public void mouseClicked(MouseEvent e) {
			}

		});
	}

	@Override
	public void paintComponent(Graphics g) {
		Paint paint;
		Graphics2D g2d;
		if (g instanceof Graphics2D) {
			g2d = (Graphics2D) g;
		} else {
			System.out.println("Error");
			return;
		}
		paint = new GradientPaint(0, 0, couleurBas, 0, getHeight(), couleurFond);
		g2d.setPaint(paint);
		g2d.fillRoundRect(0, 0, getWidth(), getHeight(), 20, 20);
		g2d.setColor(couleurNormale);
		g2d.setStroke(new BasicStroke(3));
		g2d.drawRoundRect(0, 0, getWidth(), getHeight(), 20, 20);
	}
}
